$(document).ready(function () {
    wfwzxx.onload();
})
var wfwzxx = (function () {
	var init = function () {
    	layui.use('form', function(){
			  var form = layui.form
		});
    }
    return {
        onload : function () {
        	init();
            wfwzxx.tableDataWfwz();
            wfwzxx.dateShow();
        },
       /*表格数据交互*/
      tableDataWfwz: function() {
 		var data = [{
 				"number": "1",
 				"ajNumber": "未到期应缴",
 				"ajName": "违反税收管理",
 				"wfwzName":"违反税收管理",
 				"skStart": "2018-08-22",
 				"skFinish": "2018-08-23",
 				"loginDate":"2018-07-23",
 				"state": "处理完毕",
 				"fkMoney":'1,000.00'
 			},
 			{
 				"number": "2",
 				"ajNumber": "未到期应缴",
 				"ajName": "违反税收管理",
 				"wfwzName":"违反税收管理",
 				"skStart": "2018-08-22",
 				"skFinish": "2018-08-23",
 				"loginDate":"2018-07-23",
 				"state": "处理完毕",
 				"fkMoney":'1,000.00'
 			},
 			{
 				"number": "3",
 				"ajNumber": "未到期应缴",
 				"ajName": "违反税收管理",
 				"wfwzName":"违反税收管理",
 				"skStart": "2018-08-22",
 				"skFinish": "2018-08-23",
 				"loginDate":"2018-07-23",
 				"state": "未处理",
 				"fkMoney":'1,000.00'
 			},
 			{
 				"number": "4",
 				"ajNumber": "未到期应缴",
 				"ajName": "违反税收管理",
 				"wfwzName":"违反税收管理",
 				"skStart": "2018-08-22",
 				"skFinish": "2018-08-23",
 				"loginDate":"2018-07-23",
 				"state": "处理完毕",
 				"fkMoney":'1,000.00'
 			}
 		];
 		$('#wepWfwz').DataTable({
 			"data": data,
 			"columns": [
 			    {
 					"data": "number"
 				},
 				{
 					"data": "ajNumber"
 				},
 				{
 					"data": "ajName"
 				},
 				{
 					"data": "wfwzName"
 				},
 				{
 					"data": "skStart"
 				},
 				{
 					"data": "skFinish"
 				},
 				{
 					"data": "loginDate"
 				},
 				{
 					"data": "state"
 				},
 				{
 					"data": "fkMoney"
 				}
 			],
// 			"paging": false,
 			"info": false,
 			"ordering": false,
 			"lengthChange": false,
 			"searching": false,
 			"fnInitComplete": function (oSettings, json) {/*判断认证状态显示字体颜色*/
	            for(var i=0;i<$('#wepWfwz tbody tr').length;i++){
	            	if($('#wepWfwz tbody tr').eq(i).find('td').eq(7).text() == "处理完毕"){
	            		$('#wepWfwz tbody tr').eq(i).find('td').eq(7).addClass('font1')
	            	}else{
	            		$('#wepWfwz tbody tr').eq(i).find('td').eq(7).addClass('font2')
	            	}
	            }
	        }
 		});
    },
     /*日期显示*/
        dateShow:function(){
        	layui.use('laydate', function(){
			  var laydate = layui.laydate;
			  function dateObj(dom1,dom2){//结束时间不小于开始时间
					var startDate   = laydate.render({
						elem: dom1,
						done:function(value,date){
							if( value !== '' ){
								endDate.config.min.year = date.year;
								endDate.config.min.month = date.month - 1;
								endDate.config.min.date = date.date;
							}else{
								endDate.config.min.year = '';
								endDate.config.min.month = '';
								endDate.config.min.date = '';
							}
						}
					});
					var endDate  = laydate.render({
						elem: dom2,
						done:function(value,date){
							if( value !== '' ){
								startDate.config.max.year = date.year;
								startDate.config.max.month = date.month - 1;
								startDate.config.max.date = date.date;
							}else{
								startDate.config.max.year = '';
								startDate.config.max.month = '';
								startDate.config.max.date = '';
							}
						}
					});
				}
				dateObj('#wep_date1','#wep_date2');
			})
        }
    }
})();